import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import Componts from "unplugin-vue-components/vite" //  自动注册组件
import { VantResolver } from "unplugin-vue-components/resolvers" //  按需加载自定义组件
import AutoImport from "unplugin-auto-import/vite" //  自动导入api

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({ imports: ['vue', 'vue-router'] }),
    Componts({
      dts: true,
      dirs: ['src/components', 'src/views'],
      resolvers: [
        VantResolver()
      ]
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
